Fix NPE in DatabaseClientDecorator when JDBC connection has no db type - #12371
Fix NPE in DatabaseClientDecorator when JDBC connection has no db type#12371dougqh wants to merge 1 commit into
Conversation
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
343288d to
bec931e
Compare
processDatabaseType/dbService dereferenced the NamingEntry returned by CACHE.computeIfAbsent(dbType, NamingEntry::new) without checking for null. FixedSizeCache.computeIfAbsent returns null for a null key without invoking the producer, so a null dbType() (e.g. an undetermined DBInfo.getType()) led to a NullPointerException in tracing instrumentation instead of a graceful no-op. Guard on dbType == null directly instead of inferring it from the cache's return value, and add a test exercising both methods with a null dbType. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bec931e to
0dd0abe
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
More details
The null guards prevent both null dereferences. They keep the existing behavior for non-null database types.
🤖 Datadog Autotest · Commit 0dd0abe · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for 28d87a9: What to do next?
DetailsSince those jobs are not marked as being allowed to fail, the pipeline will most likely fail. |
What Does This Do
Guards
DatabaseClientDecorator.processDatabaseType()anddbService()against anulldbType, instead of letting them NPE.CACHE.computeIfAbsent(dbType, NamingEntry::new)returnsnullfor anullkey without invoking the producer (FixedSizeCache.computeIfAbsent,internal-api/.../FixedSizeCache.java:71-73). WhendbTypeisnull— e.g.JDBCDecorator.onConnectionpassing aDBInfo.getType()that couldn't be determined — the returnedNamingEntrywas dereferenced immediately afterward, throwing an NPE inside tracer instrumentation instead of degrading gracefully.processDatabaseType/dbService: checkdbType == nullup front and return early, rather than inferring the null case from the cache's return value.DatabaseClientDecoratorNullDbTypeTestcovering both methods with anulldbType.Motivation
Fixes a NullPointerException reported in Error Tracking (issue, 1300+ occurrences, first seen 2026-02-16, service
mainframe-gatewayvia JDBC instrumentation):Additional Notes
/techdebtand/perf-reviewboth came back clean: no duplication/complexity concerns, and the null-guards are a strict improvement on the previously-crashing path with no added cost on the normal path.🤖 Generated with Claude Code
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueJira ticket: [PROJ-IDENT]